package bookStore.service.business;

import java.util.List;

import bookStore.dao.business.AuthorDao;
import bookStore.dao.business.AuthorDaoImpl;
import bookStore.dao.business.BookDao;
import bookStore.dao.business.BookDaoImpl;
import bookStore.po.Author;
import bookStore.service.ServiceTemplate;
import bookStore.vo.AuthorVo;

public class AuthorServiceImpl extends ServiceTemplate implements AuthorService {
	AuthorDao dao;
	BookDao bookDao;
	
	public AuthorServiceImpl() {
		this.dao=new AuthorDaoImpl(this.connection);
		bookDao = new BookDaoImpl(this.connection);
	}
	
	@Override
	public List<Author> queryAll(int offset, int pageSize) {
		// TODO Auto-generated method stub
		return dao.queryAll(offset, pageSize);
	}

	@Override
	public void save(Author t) {
		// TODO Auto-generated method stub

	}

	@Override
	public Author get(int id) {
		 
		return dao.get(id);
	}

	@Override
	public long count() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void update(Author t) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(int id) {
		// TODO Auto-generated method stub

	}

	@Override
	public AuthorVo getAuthorVoById(int authorId) {
		Author author = this.get(authorId);
		AuthorVo authorVo = new AuthorVo();
		authorVo.setAuthorId(author.getId());
		authorVo.setAuthorName(author.getName());
		authorVo.setAuthorIntroduction(author.getIntroduction());
		authorVo.setAuthorPicture(author.getPicture());
		authorVo.setNewestBooks(bookDao.queryBookWithPictureByAuthor(authorId, 0, 6));
		authorVo.setHighScoreBooks(bookDao.queryBookWithPictureByScoreAndAuthor(authorId, 0, 6));
		return authorVo;
	}

	@Override
	public String getAuthorNameById(int authorId) {
		return dao.getAuthorNameById(authorId);
	}

}
